import requests
import json

if __name__ == '__main__':
    headers = {
        'User_Agent':''
    }
    url = 'http://www.kfc.com.cn/kfccda/ashx/GetStoreList.ashx?op=keyword'
    keyword = input('请输入要查询的位置：')
    data = {
        'cname':'',
        'pid':'',
        'keyword': keyword,
        'pageIndex': '1',
        'pageSize': '30'
    }
    response = requests.post(url=url,data=data,headers=headers)
    json_data = response.json()
    file_name = keyword+'.json'
    f = open(file_name,'w',encoding='utf-8')
    json.dump(json_data,f,ensure_ascii=False)
    f.close()
    print('爬取完毕！')